<template>
  <div id="app">
      <router-view></router-view>
  </div>
</template>

<script>
  import { MessageBox } from 'mint-ui';
  export default {
    data(){
      return{

      }
    },
    methods:{
    },
    watch:{
      "$route.path" (val){
        if(val==='/index'){
          this.$store.state.tabState = '1'
        }else if(val==='/trans'){
          this.$store.state.tabState = '2'
        }else if(val==='/mine'){
          this.$store.state.tabState = '3'
        }
      }
    },
    created(){
      let that = this;
      document.addEventListener('plusready', function() {
        var webview = plus.webview.currentWebview();
        plus.key.addEventListener('backbutton', function() {
          webview.canBack(function(e) {
            if(e.canBack) {
              if(that.$route.path==='/index' || that.$route.path==='/mine'|| that.$route.path==='/trans'){
                MessageBox.confirm('确定退出？').then(({ value, action }) => {
                  webview.close();
                });
              }else {
                webview.back();
              }
            } else {
              MessageBox.confirm('确定退出？').then(({ value, action }) => {
                webview.close();
              });
              //hide,quit
              //plus.runtime.quit();
            }
          })
        });
      });
    }

  }
</script>

<style>

</style>
